package com.quick.develop.flowable.service.process.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quick.develop.flowable.domain.rule.BpmProcessRule;
import com.quick.develop.flowable.mapper.BpmProcessRuleMapper;
import com.quick.develop.flowable.service.process.IBpmProcessRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * @author junyuan.liu
 * @description: 
 * @date 2022/5/18 13:43
 */
@Service
@Validated
@Slf4j
public class BpmProcessRuleServiceImpl extends ServiceImpl<BpmProcessRuleMapper, BpmProcessRule> implements IBpmProcessRuleService {
    @Override
    public List<BpmProcessRule> getRulesByProcessDefinitionId(String processDefinitionId) {
        return baseMapper.selectListByProcessDefinitionId(processDefinitionId);
    }

    @Override
    public List<BpmProcessRule> getRulesByModelId(String modelId) {
        return baseMapper.selectListByModeId(modelId);
    }

    @Override
    public List<BpmProcessRule> getRulesByModelKey(String modelKey) {
        return baseMapper.selectListByModeKey(modelKey);
    }

    @Override
    public List<BpmProcessRule> getRules(String modelId, String nodeCode) {
        return baseMapper.selectListByModelIdAndNodeCode(modelId, nodeCode);
    }

    @Override
    public List<BpmProcessRule> getRulesByKeyNode(String modelKey, String nodeCode) {
        return baseMapper.selectListByModelKeyAndNodeCode(modelKey, nodeCode);
    }

    @Override
    public void createProcessRule(BpmProcessRule vo) {
        baseMapper.insert(vo);
    }

    @Override
    public void updateProcessRule(BpmProcessRule vo) {
        baseMapper.updateById(vo);
    }

    @Override
    public void saveProcessRule(BpmProcessRule vo) {
        this.saveOrUpdate(vo);
    }

    @Override
    public void saveProcessRuleList(List<BpmProcessRule> list) {
        this.saveOrUpdateBatch(list);
    }

    @Override
    public List<BpmProcessRule> getRulesByModeKey(String modelKey) {
        return baseMapper.selectListByModelKey(modelKey);
    }

    @Override
    public List<BpmProcessRule> getRulesListByModeKey(String modelKey) {
        return baseMapper.selectAllListByModelKey(modelKey);
    }
}
